<template>
  <div class="dynamic">
    <div></div>
    <div>
      <div>截止：2021-01-02</div>
      <div class="data">
        <el-row :gutter="5">
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <div>{{ confirmed }}</div>
              <div>累计确诊</div>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <div>5345345345345</div>
              <div>累计疑似</div>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <div>345345345334</div>
              <div>累计死亡</div>
            </div>
          </el-col>
        </el-row>
        <el-row :gutter="5">
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <div>789783737334535</div>
              <div>累计治愈</div>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <div>4531789873734</div>
              <div>累计重症</div>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="grid-content bg-purple">
              <div>13123787876364</div>
              <div>境外输入</div>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>
    <div>
      <div>国内疫情</div>
      <div class="table_data">
        <el-row>
          <el-col :span="4">
            <div class="grid-content" style="background-color:#e0e1fd">地区</div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content" style="background-color:#dd837f">
              确诊
            </div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content"  style="background-color:#f4d3aa">疑似</div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content" style="background-color:red">
              死亡
            </div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content" style="background-color:#c5eab4">治愈</div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content" style="background-color:#d2d2d2">
              境外输入
            </div>
          </el-col>
        </el-row>

        <el-row v-for="item in dataList.list" :key="item.id">
          <el-col :span="4">
            <div class="grid-content bg-purple" >{{ item.province }}</div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content bg-purple" >
              {{ item.confirmed }}
            </div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content bg-purple" >{{ item.suspected }}</div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content bg-purple" >
              {{ item.dead }}
            </div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content bg-purple" >{{ item.cure }}</div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content bg-purple" >
              {{ item.outside }}
            </div>
          </el-col>
        </el-row>
      </div>
      <el-pagination
        layout="prev, pager, next"
        :total="dataList.total"
        :page-size="obj.pageSize"
        :current-page="obj.page"
        @current-change="change_page1"
      >
      </el-pagination>
    </div>

    <div>
      <div>最新进展</div>
      <div style="background-color: #f8f8f8; padding: 10px">
        <div
          style="margin-bottom: 10px"
          v-for="(item, index) in article.list"
          :key="item.id"
        >
          <div class="logo">
            <div></div>
            <div v-if="index == 0">最新</div>
            <div>{{ item.publishTime }}</div>
          </div>
          <div
            style="background-color: #fff; padding: 10px; border-radius: 5px"
          >
            {{ item.title }}
          </div>
        </div>
      </div>
      <el-pagination
        layout="prev, pager, next"
        :total="article.total"
        :page-size="obk.pageSize"
        :current-page="obk.page"
        @current-change="change_page"
      >
      </el-pagination>
    </div>
  </div>
</template>
<script>
import { mapActions, mapState, mapGetters } from "vuex";
export default {
  data() {
    return {
      obj: {
        page: 1,
        pageSize: 4,
      },
      obk: {
        page: 1,
        pageSize: 5,
      },
      total:0,
    };
  },
    watch: {
    obk: {
      handler: function () {
        this.page_query_article(this.obk);
      },
      deep: true,
    },
    obj: {
      handler: function () {
        this.page_query(this.obj);
      },
      deep: true,
    }
  },
  computed: {
    ...mapState("dataList", ["dataList"]),
    ...mapState("article", ["article"]),

    ...mapGetters("dataList", ["confirmed"]),
  },
  created() {
    this.page_query(this.obj);
    this.page_query_article(this.obk);
  },
  methods: {
    ...mapActions("dataList", ["page_query"]),
    ...mapActions("article", ["page_query_article"]),
        change_page(val) {
      this.obk.page = val;
    },
        change_page1(val) {
      this.obj.page = val;
    },
  },
};
</script>
// scoped用来放置不同组件之间相同类名的样式污染
<style scoped>
.logo div:first-child {
  height: 10px;
  width: 10px;
  border-radius: 50%;
  background-color: #005dff;
  margin-top: 4px;
}
.logo div:nth-child(2) {
  background-color: red;
  padding: 3px;
  font-size: 12px;
  color: white;
  border-radius: 5px;
}
.logo {
  overflow: hidden;
  margin-bottom: 5px;
}
.logo div {
  float: left;
  margin-right: 5px;
}
.data .grid-content div:first-child {
  color: #ff6900;
}
.data .grid-content div {
  height: 40px;
  line-height: 40px;
  text-align: center;
  font-weight: 800;
}
.el-row {
  margin-bottom: 5px;
  &:last-child {
    margin-bottom: 0;
  }
}
.el-col {
  border-radius: 4px;
}
.bg-purple-dark {
  background: #99a9bf;
}
.bg-purple {
  background: #fbf5ef;
}
.bg-purple-light {
  background: #e5e9f2;
}
.table_data .grid-content {
  min-height: 60px;
  text-align: center;
  line-height: 60px;
}
.data .grid-content {
  border-radius: 4px;
  min-height: 80px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
</style>